<!DOCTYPE html>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<html class="win-frame">
<head>
 <title>${name_china}管理-查看${name_china}</title>
 <%@include file="/common/head.jsp" %>
 <link href="<%=request.getContextPath()%>/static/plugin/zTree/css/zTreeStyle/zTreeStyle.css" rel="stylesheet">
 <script src="<%=request.getContextPath()%>/static/plugin/zTree/js/jquery.ztree.all-3.5.min.js"></script>
</head>
<body class="iframe-page">
<div class="page-title-wrapper">
    <div class="page-title">
        <div class="page-title-text">
            <span>${name_china}管理</span>
            <span class="split"></span>
            <span>${name_china}详情</span>
        </div>
        <a id="goBack" class="btn-return distance-left" href="javascript:;"><i class="icon icon-arrow-left"></i>返回上级</a>
    </div>
    <div class="page-title-border"></div>
</div>

<form id="form">
<div class="left-wrap">
    <h3>商品SPU</h3>
    <table id="product" class="table-view">
         <tr>
	       <td class="td-title">排序号</td>
	       <td><span name="reorder"></span></td>
        </tr>
        <tr>
	       <td class="td-title">首页位置</td>
	       <td><span name="indexLocation"></span></td>
        </tr>
        <tr>
	       <td class="td-title">商品名称</td>
	       <td><span name="name"></span></td>
        </tr>
        
        <tr>
	       <td class="td-title">商品品牌</td>
	       <td><span name="brand"></span></td>
        </tr>
        
         <tr>
	       <td class="td-title">是否包邮</td>
	       <td><span name="isFreePost"></span></td>
        </tr>
         <tr>
	       <td class="td-title">是否七天退换货</td>
	       <td><span name="isServenBack"></span></td>
        </tr>
         <tr>
	       <td class="td-title">佣金比例</td>
	       <td><span name="marketProfitPercent"></span></td>
        </tr>
         <tr>
	       <td class="td-title">上市时间</td>
	       <td><span name="marketUpTime"></span></td>
        </tr>
         <tr>
	       <td class="td-title">商品主图</td>
	       <td><span name="mainImageUrl"></span></td>
        </tr>
         <tr>
	       <td class="td-title">商品轮播图</td>
	       <td><span name="bannerImageUrls"></span></td>
        </tr>
          <tr>
	       <td class="td-title">商品详情图</td>
	       <td><span name="detailImageUrls"></span></td>
        </tr>
        
        <tr>
	       <td class="td-title">供货价格</td>
	       <td><span name="productGonghuoPrice"></span></td>
        </tr>
         <tr>
	       <td class="td-title">商品优惠红包金额</td>
	       <td><span name="productHongbao"></span></td>
        </tr>
         <!-- 
          <tr>
	       <td class="td-title">商品基本价</td>
	       <td><span name="productPrice"></span></td>
        </tr> -->
        
        <tr>
	       <td class="td-title">备注</td>
	       <td><span name="note"></span></td>
        </tr>
        
    </table>
    <h3 id="productSkus">商品SKUs</h3>
    
</div>   
</form>
<script>
	//请求url
	var CONST_URL = {
	    GET_PRODUCT_PROPERTY_NAME: basePath + "${common_url}getProductPropertyName",
	    GET_PRODUCT_PROPERTY_VALUE_NAME: basePath + "${common_url}getProductPropertyValueName"
	};
   $(function(){
	   var data = ${product};
	   $("#form").form().form("loadDataView",{
   		  data : data
   	   }); 
	   
	   //动态创建商品的SKU
	   var productSkus = ${productSkus};
	   
       for( var i=0; i<productSkus.length;i++){
    	   var productSku = productSkus[i];
    	  
    	   var productPros = "";
    	   var productPropertys = productSku.productPropertys;
    	   if(productPropertys){
    		   var proPers = productPropertys.split(",");
    		   for(var j=0; j<proPers.length-1; j++){
    			   var pro = proPers[j].split(":");
    			   
    			   productPros += '<tr>'+
					 			       '<td class="td-title">'+getProductPropertyName(pro[0])+'</td>'+
					 			       '<td><span>'+getProductPropertyValueName(pro[1])+'</span></td>'+
					 		        '</tr>'
    		   }
    	   }
    	   
    	   var isMain = "否";
    	   if( "001"==productSku.isMain ){
    		   isMain = "是";
    	   }
    	   
    	   $("#productSkus").after('<h4>&nbsp;</h4><table id="productSku'+i+'" class="table-view">'+
    		        '<tr>'+
    			       '<td class="td-title">是否为主高品</td>'+
    			       '<td><span>'+isMain+'</span></td>'+
    		        '</tr>'+
    		        '<tr>'+
	 			       '<td class="td-title">商品轮播图</td>'+
	 			       '<td><span>'+productSku.bannerUrls+'</span></td>'+
	 		        '</tr>'+
	 		        productPros+
	 		       '<tr>'+
	 			       '<td class="td-title">商品库存</td>'+
	 			       '<td><span >'+productSku.productInventory+'</span></td>'+
	 		        '</tr>'+
	 		       '<tr>'+
	 			       '<td class="td-title">商品原价</td>'+
	 			       '<td><span >'+productSku.productOrginPrice+'</span></td>'+
	 		        '</tr>'+
	 		       '<tr>'+
				       '<td class="td-title">商品红包</td>'+
				       '<td><span >'+productSku.productHongbao+'</span></td>'+
			        '</tr>'+
			        '<tr>'+
				       '<td class="td-title">商品现价</td>'+
				       '<td><span >'+productSku.productPrice+'</span></td>'+
			        '</tr>'+
    		    '</table>'); 
       }
	   
	   $('#goBack').on('click', backHome);
   });
   
   function getProductPropertyName(id){
	   var result = "";
	   $.ajax({
		   async:false,
		   type: 'get',
		   url: CONST_URL.GET_PRODUCT_PROPERTY_NAME+"?id="+id,
		   success:function(data){
			   //alert(data.name)
			   result = data.name;
		   }
	   });
	   return result;
   }
   function getProductPropertyValueName(id){
	   var result = "";
	   $.ajax({
		   async:false,
		   type: 'get',
		   url: CONST_URL.GET_PRODUCT_PROPERTY_VALUE_NAME+"?id="+id,
		   success:function(data){
			   //alert(data.propertyValue)
			   result = data.propertyValue;
		   }
	   });
	   return result;
   }
   function backHome() {
      window.location.href =  basePath + "${common_url}initList?categoryId=${categoryId}";
   }
</script>
</body>
</html>